package com.itheima03.day14;

/**
 * @author 刘全
 * @date 2021/8/7
 */
public class Cooker extends Thread{
    @Override
    public void run() {
        while (true) {
            synchronized (Desk.obj) {
                if (Desk.count == 0) {
                    break;
                } else {
                    if (Desk.flag == true) {
                        try {
                            Desk.obj.wait();
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    } else {
                        Desk.flag = true;
                        System.out.println("厨师正在做菜");
                        Desk.obj.notify();
                    }
                }
            }
        }
    }
}
